package com.lycx.businessmanager.dao;

import java.util.List;

import org.apache.ibatis.session.RowBounds;
import org.mybatis.spring.support.SqlSessionDaoSupport;

public class BaseDao extends SqlSessionDaoSupport {

	 
	@SuppressWarnings("rawtypes")
	public List select(String statement,Object object){
		return this.getSqlSession().selectList(statement,object);
	}
	

	public Object selectOne(String statement,Object object){
		return this.getSqlSession().selectOne(statement,object);
	}
	
	public int insert(String statement,Object object){
		return this.getSqlSession().insert(statement,object);
	}
	
	/**
	 * @param statement
	 * @param object
	 * @return 修改的记录条数
	 */
	public int update(String statement,Object object){
		return this.getSqlSession().update(statement, object);
	}
	
	/**
	 * @param statement
	 * @param object
	 * @return 删除的记录条数
	 */
	public int delete(String statement,Object object){
		return this.getSqlSession().delete(statement, object);
	}

	/**
	 * @param statement
	 * @return 总记录数
	 */

	public int count(String statement,Object object){
		int count = 0;
		Object obj = this.getSqlSession().selectOne(statement, object);
		count = ((Integer)obj).intValue();
		return count;
	}
	
	/**
	 * 分页查询方法
	 * @param statement
	 * @param object
	 * @param start
	 * @param limit
	 * @return
	 */
	@SuppressWarnings("rawtypes")
	public List selectForPagination(String statement,Object object,int start,int limit){
		RowBounds rowBounds = new RowBounds(start, limit); 
		return this.getSqlSession().selectList(statement, object, rowBounds);
	}

}
